package org.yuangu.privacyfinance.domain.access;

import org.yuangu.privacyfinance.domain.model.Account;

import java.util.List;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Query;

/**
 * 账户数据表访问类
 */
@Dao
public abstract class AccountDao extends AbstractDao<Account> {

    /**
     * 获取账户总数
     * @return 账户总数
     */
    @Query("SELECT COUNT(*) FROM Account")
    public abstract long count();

    /**
     * 获取对应账户Id的账户实体
     * @param id 账户Id
     * @return 账户实体
     */
    @Override
    @Query("SELECT * FROM Account WHERE id=:id")
    public abstract LiveData<Account> get(long id);

    /**
     * 获取所有账户列表
     * @return 账户列表
     */
    @Override
    @Query("SELECT * FROM Account")
    public abstract LiveData<List<Account>> getAll();
}